import { getErrorMessage } from '@/utils/error'
import chalk from 'chalk'
import dayjs from 'dayjs'

// const outputTimestamp = typeof OUTPUT_TIMESTAMP === 'undefined' ? true : OUTPUT_TIMESTAMP

function output(message: any) {
  const msg = getErrorMessage(message)
  console.log(`${time()} ${msg}`)
}

output.error = function (message: any) {
  const msg = getErrorMessage(message)
  console.log(`${time()} ${chalk.red(msg)}`)
}

output.warning = function (message: any) {
  const msg = getErrorMessage(message)
  console.log(`${time()} ${chalk.yellow(msg)}`)
}

function time() {
  return chalk.dim(dayjs().format('YYYY/MM/DD HH:mm:ss'))
}

export default output
